<template>
  <div>
    <Card style="width:100%">
      <row type="flex" justify="space-between">
        <i-col>

          <span class="key" style="margin-left: 20px">订单号</span>
          <Input v-model="orderNo" placeholder="请输入订单号" class="width-condition" style="width: 200px;margin-left: 20px"/>

          <span class="key" style="margin-left: 50px">工艺代码</span>
          <Select v-model="productCode" style="width: 180px;margin-left: 20px">
            <Option v-for="item in productList" :value="item.code" :key="item.code">{{ item.code }}</Option>
          </Select>

          <Button type="success"  icon="ios-search" style="margin-left: 50px" @click="find">查询</Button>
        </i-col>
      </row>
    </Card>
    <Table stripe :columns="columns" :data="data"></Table>

    <row style="margin-top: 10px">
      <i-col align="right">
        <Page show-sizer :total="total" show-total @on-change="onChange" @on-page-size-change="onPageSizeChange"/>
      </i-col>
    </row>

  </div>
</template>

<script>
  import {StockFindAll,ProductFindAll} from "../../../api/data"

  export default {
    data() {
      return {
        page: 1,//page 第几页
        pageSize: 10,//pageSize:每页几条数据
        total: 0,
        materialCode:'',
        operator:'',
        storageTime:'',
        columns: [
          {
            title: '代码',
            key: 'code'
          },
          {
            title: '原料代码',
            key: 'materialCode'
          },
          {
            title: '篮子重量',
            key: 'basketWeight'
          },
          {
            title: '原料重量',
            key: 'materialWeight'
          },
          {
            title: '数量',
            key: 'quantity'
          },
          {
            title: '单件重量',
            key: 'pieceWeight'
          },
          {
            title: '操作人员',
            key: 'operator'
          },
          {
            title: '存放时间',
            key: 'storageTime'
          },
          {
            title: '状态',
            key: 'state'
          },
          {
            title: '操作',
            key: 'action',
            width: 150,
            align: 'center',
            render: (h, params) => {
              return h('div', [
                h('Button', {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      this.$router.push({
                        path: '/base-setting/order-update', query: {
                          orderNo: params.row.orderNo,
                        }
                      })
                    }
                  }
                }, '编辑'),

              ]);
            }
          }

        ],
        data: []
      }
    },
    mounted() {
      this.OrderFindAll();
      this.ProductFindAll();
    },
    methods: {
      find(){
        this.StockFindAll();
      },
      StockFindAll() {
        var data = {
          operator:this.operator,
          materialCode:this.materialCode,
          storageTime:this.storageTime,
          page: this.page,
          pageSize: this.pageSize,
        };
        StockFindAll(data).then(data => {
          if (data.data.code == 0) {
            this.data = data.data.data.list;
            this.total = data.data.data.total;
          }
        })
      },
      ProductFindAll() {
        var data = {
          page: this.page,
          pageSize: 1000,
        };
        ProductFindAll(data).then(data => {
          if (data.data.code == 0) {
            this.productList = data.data.data.list;
          }
        })
      },
      onPageSizeChange(pageSize) {
        this.page = 1;
        this.pageSize = pageSize;
        this.StockFindAll();
      },
      onChange(page) {
        this.page = page;
        this.StockFindAll();
      },
    }
  }
</script>


